commonlibsse_ng\re\b/
BGSPerkEntry.rs

1use core::ffi::c_void;
2
3use crate::re::Actor::Actor;
4use crate::re::BGSEntryPoint::EntryPoint;
5use crate::re::FormTypes::FormType;
6use crate::re::TESFile::TESFile;
7use crate::re::offsets_rtti::RTTI_BGSPerkEntry;
8use crate::re::offsets_vtable::VTABLE_BGSPerkEntry;
9use crate::rel::id::VariantID;
10
11#[repr(C)]
12#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
13pub struct BGSPerkEntry {
14    pub vtable: *const BGSPerkEntryVtbl, // 0x0
15    pub header: Header,                  // 0x8
16}
17const _: () = assert!(core::mem::size_of::<BGSPerkEntry>() == 0x10);
18
19impl BGSPerkEntry {
20    /// Address & offset of the runtime type information (RTTI) identifier.
21    pub const RTTI: VariantID = RTTI_BGSPerkEntry;
22
23    /// Address & offset of the virtual function table.
24    ///
25    /// The number of tables is the same as the number of classes with inherited virtual functions.
26    pub const VTABLE: [VariantID; 1] = VTABLE_BGSPerkEntry;
27
28    /// The `FormType` value for BGSPerkEntry.
29    pub const FORM_TYPE: FormType = FormType::Perk;
30
31    #[inline]
32    pub const fn get_rank(&self) -> u8 {
33        self.header.rank
34    }
35
36    #[inline]
37    pub const fn get_priority(&self) -> u8 {
38        self.header.priority
39    }
40}
41
42#[repr(C)]
43pub struct BGSPerkEntryVtbl {
44    CheckConditionFilters: fn(this: &mut BGSPerkEntry, num_args: u32, args: *mut c_void) -> bool, // 00 - { return false; }
45    GetFunction: fn(this: &mut BGSPerkEntry) -> EntryPoint, // 01 - { return 0; }
46    GetFunctionData: fn(this: &BGSPerkEntry) -> *mut c_void, // 02 - { return 0; }
47    CxxDrop: fn(this: &mut BGSPerkEntry),
48    GetType: fn(this: &BGSPerkEntry) -> PERK_ENTRY_TYPE_CEnum, // 0x04
49    ClearData: fn(this: &mut BGSPerkEntry),                    // 0x05 - { return; }
50    InitItem: fn(this: &mut BGSPerkEntry, owner: *mut TESFile), // 0x06 - { return; }
51    Load: fn(this: &mut BGSPerkEntry, file: *mut TESFile) -> bool, // 0x07 - { return true; }
52    SetParent: fn(this: &mut BGSPerkEntry),                    // 0x08 - { return; }
53    GetID: fn(this: &BGSPerkEntry) -> u16,                     // 0x09 - { return 0xFFFF; }
54    ApplyPerkEntry: fn(this: &mut BGSPerkEntry, actor: *mut Actor), // 0x0A
55    RemovePerkEntry: fn(this: &mut BGSPerkEntry, actor: *mut Actor), // 0x0B
56}
57
58#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
59#[repr(C)]
60pub struct Header {
61    rank: u8,     // 0x1
62    priority: u8, // 0x2
63    unk2: u16,    // 0x3
64    unk4: u32,    // 0x4
65}
66const _: () = assert!(core::mem::size_of::<Header>() == 0x8);
67
68#[commonlibsse_ng_derive_internal::ffi_enum]
69#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
70#[repr(u32)]
71pub enum PERK_ENTRY_TYPE {
72    Quest = 0,
73    Ability = 1,
74    EntryPoint = 2,
75}